<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>林荣辉的产品管理系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        .container {
            margin-top: 20px;
        }
        .product-card {
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <div class="container-fluid">
            <a class="navbar-brand" href="/products">林荣辉的产品管理系统</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link active" href="/products">产品列表</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/products/add">添加产品</a>
                    </li>
                </ul>
            </div>
            <div class="d-flex">
                <span class="navbar-text me-3" th:text="${session.username}"></span>
                <a href="/logout" class="btn btn-outline-danger">退出登录</a>
            </div>
        </div>
    </nav>

    <div class="container">
        <h2 class="text-center mb-4">产品列表</h2>
        
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <h5 class="card-title">所有产品</h5>
                    </div>
                    <div class="card-body">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>名称</th>
                                    <th>描述</th>
                                    <th>价格</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr th:each="product : ${products}">
                                    <td th:text="${product.id}"></td>
                                    <td th:text="${product.name}"></td>
                                    <td th:text="${product.description}"></td>
                                    <td th:text="${product.price}"></td>
                                    <td>
                                        <a href="#" th:href="@{/products/edit/{id}(id=${product.id})}" class="btn btn-sm btn-primary">编辑</a>
                                        <a href="#" th:href="@{/products/delete/{id}(id=${product.id})}" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除吗？')">删除</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>    